<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_505040_qmncju4rgtu766r.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/global/mui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/global/public.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/map-more.css"/>
		<title>到店取药</title>
	</head>
	<body>
		<ul class="map-list font3">
			<!--<li>
				<div>
					<span>
						湖北宜昌
						<p>湖北宜昌湖北宜昌湖北宜昌湖北宜昌</p>
					</span>
					<font>
						距离800m
						<p class="color_blue"><i class="iconfont icon-024"></i></p>
					</font>
				</div>
			</li>-->
		</ul>
	</body>
</html>
<!--公共方法-->
<script type="text/javascript" src="../../js/common/common.js"></script>
<script type="text/javascript" src="../../js/module/utilModule.js" ></script> 
<!--配置信息-->
<script type="text/javascript" src="../../js/common/config.js"></script>
<script type="text/javascript" src="../../js/lib/zepto.min.js"></script>
<!--自定义模块-->
<script type="text/javascript" src="../../js/lib/mui.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="../../js/module/onlineContinuationModule.js"></script>
<script type="text/javascript" src="../../js/module/userCenterModule.js" ></script>

<script>
$(function() {	
	var orderid = utilModule.getQueryString("orderid")
	//获取ApiSign
	function initGetJsApiSign(url) {
		var params = {
			"url" : url
		};
		userCenterModule.getJsApiSign(params, function(callback) {
			var info = callback;
			if (info != null) {
				wx.config({
					debug : false,  /*正常模式*/   // true开启调试模式 //  
					appId : info.appId,
					timestamp : info.timestamp, // 必填，生成签名的时间戳
					nonceStr : info.nonceStr, // 必填，生成签名的随机串
					signature : info.signature, // 必填，签名，见附录1
					jsApiList : [ 'scanQRCode', 'getLocation']
				});
			}
		});
	}
       
	initGetJsApiSign("n/html/prescription/map-more.html?orderid="+orderid);
	 
	wx.ready(function(){ 
	   wx.getLocation({
	    	success: function(res) {
	    		console.log("###############"+res);
		        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
		        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
		        //去数据库查询获取附近的门店
	            utilModule.get({
	                url: "prescription/getBestPharmacy",
	                data: {"latitude":latitude,"longitude":longitude},
	                needJson: false, 
	                async: false,
	                success: function (response) {
	                	var html='';
	                	for(i in response){
	                		var url = "http://apis.map.qq.com/tools/poimarker?type=0&marker=coord:"+response[i].lat+","+response[i].lon+";title:"+response[i].name+";addr:"+response[i].address+"&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myappr=myapp";
	                		html+='<li url="'+url+'">'
									+'<div>'
										+'<span>'
											+response[i].name
											+'<p>'+response[i].address+'</p>'
										+'</span>'
										+'<font>';
											if(response[i].juli<1000){
												html+=response[i].juli+"m"
											}else{
												html+=(Math.round(response[i].juli/10)/100).toFixed(2) + "km"
											}
											html+='<p class="color_blue"><i class="iconfont icon-024"></i></p>'
										+'</font>'
									+'</div>'
								+'</li>';
									
	                    }
	                	$(".map-list").append(html);
	                	
	                	$(".map-list li").on("click",function(){
	                		var url = $(this).attr("url");
	                		location.href = url;
	                	});
	                }
	            });
			}
		});
		wx.error(function(res) {
			mui.alert("返回结果：" + res.errMsg);
		});
	});	
});
</script>